#ifndef __THREAD_POOL_H_
#define __THREAD_POOL_H_
#include<pthread.h>

/*任务*/
struct Task_t
{
    /*回调函数*/
    void *(*function)(void *arg);
    /*回调函数的参数*/
    void *arg;

};

class ThreadPool
{
public:
    ThreadPool(int minThread,int maxThread,int maxQueueCapacity);
public:
    /*添加任务*/
    void addTask(void *(function)(void *arg),void*arg);
public:
    /*队列的容量*/
    int m_queueCacity;
    /*任务队列*/
    Task_t *m_queue;
    /*任务队列的元素个数*/
    int m_queueSize;
    /*任务队列的对头*/
    int m_queueFront;

    /*任务队列的队尾*/
    int m_queueRear;
    
    /*工作线程*/
    pthread_t *m_threadIds;
    /*管理者线程*/
    pthread_t  m_manageId;

    /*最小线程数*/
    int m_minThreads;
    /*最大线程数*/
    int m_maxThreads;
    /*忙碌的线程数*/
    int m_busyThreads;
    /*存活的线程数*/
    int m_aliveThreads;

    /*锁*/
    pthread_mutex_t m_mutex;
    /*忙碌的锁*/
    pthread_mutex_t m_busyMutex;
    /*条件变量*/
    pthread_cond_t m_notEmpty;
    pthread_cond_t m_notFull;

    /*要删除的线程数量*/
    int m_exitNum;


private:





};
























#endif